package com.woniu.product.controller;

import com.woniu.entity.Result;
import com.woniu.product.pojo.Category;
import com.woniu.product.pojo.Product;
import com.woniu.product.service.ICategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lydia
 * @since 2023-02-16
 */
@RestController
@RequestMapping("/category")
@Api(tags = "商品分类查询")
public class CategoryController {

    @Autowired
    private ICategoryService categoryService;

    @GetMapping("/firstLevel")
    @ApiOperation("分级分类商品查询")
    public Result<List<Category>> findParentProductByCategory(@RequestParam String parentId){//@RequestParam主要用于接收http://host:port/path?参数名=参数值数据，这里后面也可以不跟参数值。
        List<Category> parentProductByCategory = categoryService.findParentProductByCategory(parentId);
        return Result.ok(parentProductByCategory);
    }
}
